package com.chenfan.mcn.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.mcn.clients.privilege.SCompanyBank;
import com.chenfan.mcn.dao.StarMonthlySettlementMapper;
import com.chenfan.common.extension.mybatisplus.enhanced.EnhancedService;
import com.chenfan.mcn.model.StarMonthlySettlement;
import com.chenfan.mcn.model.StarMonthlySettlementSub;
import com.chenfan.mcn.model.common.KVPair;
import com.chenfan.mcn.model.dto.*;
import com.chenfan.mcn.model.rpc.ChargeClearCallback;
import com.chenfan.mcn.model.vo.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 红人月度结算单 服务类
 * </p>
 *
 * @author wulg
 * @since 2022-01-13
 */
public interface StarMonthlySettlementService extends EnhancedService<StarMonthlySettlementMapper, StarMonthlySettlement> {

    /**
     * 分页查询接口
     * @param searchDTO
     * @return
     */
    Page<StarMonthlySettlementListVO> getPage(StarMonthlySettlementSearchDTO searchDTO);

    /**
     * 新增-红人月度结算单
     *
     * @param saveDTO
     * @return Integer
     */
    Long addSettlement(StarMonthlySettlementSaveDTO saveDTO);

    /**
     * 修改-红人月度结算单
     *
     * @param saveDTO
     * @return exportSubSettlement
     */
    boolean modifySettlement(StarMonthlySettlementSaveDTO saveDTO);

    /**
     * 添加执行单明细-分页查询
     * @param queryDTO
     * @return
     */
    Page<StarMonthlySettlementExcutionOrderVO> getExcutionOrders(StarMonthlySettlementExcutionOrderQueryDTO queryDTO);

    /**
     * 分页查询结算单明细
     * @param queryDTO
     * @return
     */
    Page<StarMonthlySettlementDetailListVO> getDetailPage(StarMonthlySettlementDetailQueryDTO queryDTO);

    /**
     * （批量）新增结算单明细
     * @param dto
     * @return
     */
    boolean addDetails(StarMonthlySettlementDetailAddDTO dto);

    /**
     * 修改结算单明细
     * @param dto
     * @return
     */
    boolean modifyDetail(StarMonthlySettlementDetailModifyDTO dto);

    /**
     * 删除结算单明细
     * @param dto
     * @return
     */
    boolean deleteDetails(StarMonthlySettlementDetailDeleteDTO dto);

    /**
     * 批量添加执行单-导入Excel
     * @param id
     * @param inputList
     * @return
     */
    String importDetails(Long id, List<RelatedExcutionOrderInputDTO> inputList);


    /**
     * 批量HR计税审批-导入Excel
     * @param inputList
     * @return
     */
    String importAccruedTax(List<AccruedTaxInputDTO> inputList);

    /**
     * 下载失败原因
     *
     * @param response {@link HttpServletResponse}
     * @param fileId
     */
    void excelDownload(HttpServletResponse response, String fileId);

    /**
     * 审批时-HR计税
     * @param dto
     * @return
     */
    BigDecimal accruedTax(StarMonthlySettlementTaxDTO dto);

    /**
     * 审批时-提交人录入发票信息
     * @param dto
     * @return
     */
    boolean inputInvoice(StarMonthlySettlementSubmiterDTO dto);

    /**
     * 审批时-财务审批录入确认打款金额
     * @param dto
     * @return
     */
    boolean financeExamine(StarMonthlySettlementFinanceExamineDTO dto);

    /**
     * 红人月度结算单-修改单据状态
     *
     * @param id {@link Long}
     * @param approvalStatus   {@link Integer}
     * @return {@link Boolean}
     */
    boolean changeStatus(Long id, Integer approvalStatus);

    /**
     * 核销后回款回调
     *
     * @param dto 回款报文
     * @param starMonthlySettlementSub
     * @return
     */
    boolean updatePayback(ChargeClearCallback dto, StarMonthlySettlementSub starMonthlySettlementSub);


    /**
     * 获取结算单
     * @param settlementId
     * @param verifyExist
     * @return
     */
    StarMonthlySettlement getSettlement(Long settlementId, boolean verifyExist);

    /**
     * 获取子结算单
     * @param subSettlementId
     * @param verifyExist
     * @return
     */
    StarMonthlySettlementSub getSettlementSub(Long subSettlementId, boolean verifyExist);

    /**
     * 红人月度结算单-打款金额汇总
     * @param id
     * @return
     */
    StarMonthlySettlementPaySummaryVO paySummary(Long id);

    /**
     * 红人月度结算单-详情
     * @param id
     * @return
     */
    StarMonthlySettlementDetailVO detail(Long id);

    /**
     * 红人月度结算单-导出线上执行单
     * @param id
     * @return
     */
    KVPair<String, List<StatementPerformListExportVO>> exportSubSettlement(Long id);

    /**
     * 红人月度结算单-导出结算单明细
     * @param queryDTO
     * @return
     */
    List<StarMonthlySettlementDetailExportVO> exportSettlementDetail(StarMonthlySettlementDetailQueryDTO queryDTO);

    /**
     * 红人月度结算单-导出结算单明细 修改后版本
     * @param queryDTO
     * @return
     */
    List<StatementPerformListExportVO> exportSettlementDetailList(StarMonthlySettlementDetailQueryDTO queryDTO);
    /**
     * 导出单个红人月度结算单
     * @param id
     * @return
     */
    KVPair<String, List<StarMonthlyOneSettlementExportVO>> exportOneStatement(Long id);

    /**
     * 导出红人月度结算单列表
     * @param searchDTO
     * @return
     */
    KVPair<String, List<StatementListExportVO>> exportStatementList(StarMonthlySettlementSearchDTO searchDTO);

    /**
     * 红人月度结算单列表-执行单明细导出
     * @param searchDTO
     * @return
     */
    KVPair<String, List<StatementPerformListExportVO>> exportStatementPerformList(StarMonthlySettlementSearchDTO searchDTO);

    /**
     * 红人月度结算单-打印
     * @param subSettlementCode
     * @return
     */
    StarMonthlySettlementPrintVO getStarMonthlySettlementPrint(String subSettlementCode);

    /**
     * 查询公司账户信息-财务调用
     * @param chargeSourceCode
     * @return
     */
    FinanceSettleInfoVO getFinanceSettleInfo(String chargeSourceCode);

    /**
     * 根据子结算单号获取子结算单信息
     *
     * @param subSettlementCode
     * @param verifyExist
     * @return StarMonthlySettlementSub
     */
    StarMonthlySettlementSub getSubSettlementByCode(String subSettlementCode, boolean verifyExist);

    /**
     * 根据结算单号获取结算单信息
     * @param settlementCode
     * @param verifyExist
     * @return
     */
    StarMonthlySettlement getSettlementByCode(String settlementCode,  boolean verifyExist);

    /**
     * 根据子结算单获取默认打款信息
     * @param subSettlementCode
     * @return
     */
    PaidInfoDetailVO getDefaultPaidInfoByCode(String subSettlementCode);

    /**
     * 根据子结算单获取默认打款信息
     * @param subSettlementCode
     * @return
     */
    SCompanyBank getScompanyBankByCode(String subSettlementCode);

    /**
     * 复制作废的结算单
     * @param id
     * @return
     */
    Long copyInvaild(Long id);


    /**
     * 通过执行单ID获取关联的结算单信息
     * @param excuteId
     * @return
     */
    StarMonthlySettlement getSettlementByExcuteId(Long excuteId);

    /**
     * 确认付款
     * @param ids 结算单明细ID 数组
     */
    void confirmPayment(List<Long> ids);


    /**
     * 取消付款
     * @param ids 结算单明细ID 数组
     */
    void cancelPayment(List<Long> ids);
}
